#! /bin/bash

set -ex

if [[ ! ${H2O_BRANCH} ]]; then
 echo "H2O_BRANCH must be set"
 exit 1
fi
if [[ ! -n ${PYTHON_VERSION} ]]; then
  echo "Using default Python version"
  PYTHON_VERSION='3.7'
fi

# cd home
cd

echo "###### Activate Python ${PYTHON_VERSION} ######"
. /envs/h2o_env_python${PYTHON_VERSION}/bin/activate

echo '###### Clone H2O-3 ######'
git clone https://github.com/h2oai/h2o-3
cd h2o-3
git checkout ${H2O_BRANCH}

echo '###### Build H2O-3 ######'
printenv | sort
make -f scripts/jenkins/Makefile.jenkins warmup-caches

echo '###### Cleanup ######'
rm -rf ~/h2o-3
